import { Component, OnInit } from '@angular/core';
import { Recharge } from '../../interface/recharge.interfaces';
import { ModalService, Pagination } from 'ng-tui';
import { RechargeService } from '../../service/recharge.service';
import { GlobalService, AuthService } from '../../../../cores/services';
import { HttpConfig } from '../../../../configs/http.config';
import { ApiData, SearchParams } from '../../../../cores/classes';


@Component({
    template: `
    <div class="modal-content">
    <div class="modal-header">
        <h5 class="modal-title">添加企业类型</h5>
        <button (click)="modal.dismiss()" type="button" class="close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div class="modal-body">
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">企业类型</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="banner.typeName" placeholder="请输入企业类型">
            </div>

        </div>
        <div class="modal-footer">
            <button (click)="modal.dismiss()" type="button" class="btn">取消</button>
            <button tsBtn loading (submit)="confirmSave($event)" color="success">保存</button>
        </div>
    </div>
</div>`
})
export class ModalComponent {

    conpay = new Array<any>();
    pagination = new Pagination();
    search = new SearchParams({ status: '', uid: '', orderSn: '' });

    loading = false;
    uploading = false;
    userInfo: any;
    banner: Recharge = { id: 0 };
    constructor(
        public global: GlobalService,
        public modal: ModalService,
        private rechargeService: RechargeService,
        private auth: AuthService,
    ) {
        console.log(this.auth.user);
    }

    confirmSave(btn: any) {
        (this.banner.id > 0 ? this.rechargeService.updatetype(this.banner) : this.rechargeService.inserttype(this.banner))
            .subscribe({
                next: () => this.modal.close(),
                complete: () => btn.dismiss()
            });
    }
}


